/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * mainFrame.java
 *
 * Created on Apr 3, 2011, 5:44:05 PM
 */
package POS_Source;

import POS_Controller.POSController;
import Session.POS_SessionManager;
import java.awt.Container;
import javax.swing.JPanel;

/**
 * this class renders main frame for gui
 * @author Spence
 * @see POS_Source
 */
public class mainFrame extends javax.swing.JFrame {

    private POSController controller;
    private POS_MainOut mainOut;

    /**
     * constructor for this class
     * @param control
     */
    public mainFrame(POSController control) {
        initComponents();
        controller = control;
        customInit();
    }

    public mainFrame(POSController control, JPanel panel) {
        initComponents();
        controller = control;
        this.setBounds(0, 0, 998, 755);
        this.setResizable(false);
        changeFrame(panel);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("DigiStore");
        setBackground(new java.awt.Color(255, 255, 255));
        setPreferredSize(new java.awt.Dimension(1065, 800));
        setResizable(false);
        setSize(new java.awt.Dimension(1065, 800));

        jPanel1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        jPanel1.setPreferredSize(new java.awt.Dimension(1065, 800));

        org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 1063, Short.MAX_VALUE)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 798, Short.MAX_VALUE)
        );

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    /**
     * this method overrides default view rendering
     */
    private void customInit() {
        this.setBounds(0, 0, 998, 755);
        this.setResizable(false);
        POS_Welcome welcome = new POS_Welcome(controller);
        welcome.setBounds(0, 0, 995, 733);

        jPanel1.add(welcome);
    }

    /**
     * this method directs the control to main out view via controller
     */
    public void mainOutScreen() {
        mainOut = new POS_MainOut(controller);
        jPanel1.removeAll();
        mainOut.setBounds(0, 0, 995, 733);
        jPanel1.add(mainOut);
        mainOut.changeScreen(new POS_SearchChoice(controller));
        jPanel1.validate();
        jPanel1.repaint();
    }

    /**
     * this method makes the panel to be visible dynamically
     * @param panel
     */
    public void changeFrame(JPanel panel) {
        jPanel1.removeAll();
        panel.setBounds(0, 0, 995, 733);
        jPanel1.add(panel);
        jPanel1.validate();
        jPanel1.repaint();
    }

    /**
     * this method calls change view
     * @param panel
     */
    public void changeScreen(JPanel panel) {
        mainOut.changeScreen(panel);
    }

    /**
     * this method updates dynamic receipt
     */
    public void setTotals() {
        mainOut.setTotals();
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel jPanel1;
    // End of variables declaration//GEN-END:variables
}
